<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<script src="js/jquery-1.11.0.min.js"></script>
<body>
<div>
  <form>
    <p>二类账户开户</p>
    <input type="hidden" name="id" id="id">
    姓名：<input type="text" id="name" name="name" placeholder="请输入您的姓名"> <br>
    身份证号：<input type="text" id="idNum" name="idNum" placeholder="请输入18位身份证号"> <br>
    手机号：<input type="text" id="phone" name="phone" placeholder="请输入您的11位手机号"> <br>
    支付密码：<input type="password" id="password" name="password" placeholder="请输入6位数字"> <br>
    请确认支付密码：<input type="password" id="password1" name="password1" placeholder="请确认您的密码"> <br>
  </form>
  <input type="button" value="开户" id="openAccount">
</div>


<span style="color: brown" id="error"></span><br>
<table width="100%" id="shouye">
  <tr>
    <td align="center"><a href="/airong/index.html">首页</a></td>
    <!--    <td align="center"><a href="#"><input type="button" id="lc" value="理财"></a></td>-->
    <td align="center"><a href="" id="lc">理财</a></td>
    <td align="center"><a href="/airong/personalCenter.html">我的</a></td>

  </tr>
</table>
</body>
<script>
  $("#openAccount").click(function (){
    let url = "/airong/card?action=openAccount2";
    let id =  $("#id").val();
    let name = $("#name").val();
    let idNum = $("#idNum").val();
    let phone = $("#phone").val();
    let password = $("#password").val();
    let password1 = $("#password1").val();

    let params = {id,name,idNum,phone,password,password1}

    $.post(url,params,function (data){
      if (data === "\"true\""){
        alert("开户成功")
        location.href = "account.html"
      }else if (data === "\"falsePwdLength\""){
        alert("开户失败")
        $("#error").html("密码必须为6位数字")
      }else if (data === "\"falsePwd\""){
        alert("开户失败")
        $("#error").html("两次输入的密码必须相同")
      }else if (data === "\"falseID\""){
        alert("开户失败");
        $("#error").html("身份证输入错误")
      }else {
        alert("开户失败")
        $("#error").html("请重新输入")
      }
    },"text")
  })
  let urll = "/airong/cc?action=getSessionID";
  let paramsl = {}
  $.get(urll,paramsl,function (sessionID){
    document.getElementById('lc').href= "products.html?uid="+sessionID;
  },"text")

</script>
<style>
  div {

    width: 100%;
    text-align: center;
  }
  input{
    padding: 10px;
    margin: 10px;
    text-align: left;
  }
  #shouye{
    position: absolute;
    top: 600px;
    padding: 5px;
    margin: 4px;
    background-color: bisque;
    font-size: 20px;
    text-align: center;
    z-index: 1;
  }
</style>
</html>